package zky.medicalInstitute;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

/**
 * 启动界面
 */
public class StartActivity extends AppCompatActivity {
    private Button enterBtn;
    private TextView txt_time;
    private Handler mHandler=new Handler();
    private  int count=5;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start);
        initUI();
        startToMainActivityBtn();
//        mHandler.post(runnable);
    }
    /**
     * 初始化控件
     */
    private void initUI() {
        enterBtn = findViewById(R.id.enterBtn);
        txt_time =findViewById(R.id.txt_time);
    }
    /**
     * 通过按钮进入主界面
     */
    private void startToMainActivityBtn() {
        enterBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent =new Intent();
                intent.setClass(StartActivity.this,MainActivity.class);
                startActivity(intent);
            }
        });
    }

/**
 * 通过延迟的方法进行主界面
 *
 */
//    private Runnable runnable  = new Runnable() {
//        @Override
//        public void run() {
//            mHandler.postDelayed(this,1000);
//            count--;
//            txt_time.setText(String.valueOf(count)+"s");
//            if(count==0){
//                Intent intent =new Intent();
//                intent.setClass(StartActivity.this,MainActivity.class);
//                startActivity(intent);
//                txt_time.setVisibility(View.GONE);
//
//            }
//        }
//
//    };
}